package com.tool_stdy;

import com.google.common.collect.Lists;

import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @auther: cc.ly
 * @date: 2018/12/24/024
 */

public class TestRollPol {
    static List<String> sourceList = Lists.newArrayList();
    static AtomicInteger idx = new AtomicInteger();

    static {
        sourceList.add("1");
        sourceList.add("2");
        sourceList.add("3");
        sourceList.add("4");
        sourceList.add("5");
    }

    public static String getStr() {
        int i = idx.incrementAndGet() & sourceList.size() - 1;
        return sourceList.get(Math.abs(i));
    }

    public static void main(String[] args) {
        for (int i = 0; i < 10; i++) {
            System.out.println(getStr());
        }

    }
}
